import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getxtest/basepage/basechildpage/childpage1/childpage1_view.dart';
import 'package:getxtest/basepage/basechildpage/childpage2/childpage2_view.dart';
import 'package:getxtest/basepage/basechildpage/fourpage/fourpage_view.dart';
import 'package:getxtest/basepage/basechildpage/three/three_view.dart';

import 'basepage_logic.dart';

class BasepageWidget extends GetView<BasepageLogic> {
  // final logic = Get.put(BasepageLogic());
  final PageController _controller = PageController(keepPage: true);

  @override
  Widget build(BuildContext context) {
   /* return GetRouterOutlet.builder(builder: (context, delegate, currentRoute) {
      return Scaffold(
          body: GetRouterOutlet(
            initialRoute: '/one',
            key: Get.nestedKey('/basepage'),
          ),
          bottomNavigationBar: GetBuilder<BasepageLogic>(builder: (logic) {
            return BottomNavigationBar(
              backgroundColor: Colors.white,
              fixedColor: Colors.red,
              currentIndex: logic.myindex,
              type: BottomNavigationBarType.fixed,
              items: const [
                BottomNavigationBarItem(icon: Icon(Icons.find_in_page), label: '首页', activeIcon: Icon(Icons.find_in_page_outlined)),
                BottomNavigationBarItem(icon: Icon(Icons.circle_notifications), label: '圈子', activeIcon: Icon(Icons.circle_notifications_outlined)),
                BottomNavigationBarItem(
                    icon: Icon(Icons.message),
                    label: '消息',
                    activeIcon: Icon(
                      Icons.message_outlined,
                    )),
                BottomNavigationBarItem(
                    icon: Icon(Icons.sanitizer),
                    label: '我的',
                    activeIcon: Icon(
                      Icons.sanitizer_outlined,
                    )),
              ],
              onTap: (int index) {
                _controller.jumpToPage(index);
                controller.setInDex(index);
              },
            );
          }));
    });*/

    return Scaffold(
        body: PageView(
          controller: _controller,
          children: [Childpage1Widget(), Childpage2Widget(),ThreePage(),FourpagePage()],
        ),
        bottomNavigationBar: GetBuilder<BasepageLogic>(builder: (logic) {
          _controller.jumpToPage(logic.myindex);
          return BottomNavigationBar(
            backgroundColor: Colors.white,
            fixedColor: Colors.red,
            currentIndex: logic.myindex,
            type: BottomNavigationBarType.fixed,
            items: const [
              BottomNavigationBarItem(icon: Icon(Icons.find_in_page), label: '首页', activeIcon: Icon(Icons.find_in_page_outlined)),
              BottomNavigationBarItem(icon: Icon(Icons.circle_notifications), label: '圈子', activeIcon: Icon(Icons.circle_notifications_outlined)),
              BottomNavigationBarItem(
                  icon: Icon(Icons.message),
                  label: '消息',
                  activeIcon: Icon(
                    Icons.message_outlined,
                  )),
              BottomNavigationBarItem(
                  icon: Icon(Icons.sanitizer),
                  label: '我的',
                  activeIcon: Icon(
                    Icons.sanitizer_outlined,
                  )),
            ],
            onTap: (int index) {
              controller.setInDex(index);
            },
          );
        }));
  }
}
